package com.seekting.mynews.connect.baidu;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;

import com.android.volley.AuthFailureError;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;
import com.seekting.mynews.App;
import com.seekting.mynews.R;
import com.seekting.mynews.manager.VolleyRequestManager;
import com.seekting.util.SLog;

public class BaiduGirl {
    private Context mContext;
    private RequestQueue requestQueue;
    private String key;
    private Response.Listener<String> listener;
    private Map<String, String> header = new HashMap<String, String>();
    private String url;

    public BaiduGirl(Context context) {
        this.mContext = context;
        key = context.getString(R.string.baidu_news_key);
        header.put("apikey", key);
        url = " http://apis.baidu.com/dajuncloud/goddess/goddesses?tuid=10";
        listener = new Response.Listener<String>() {

            @Override
            public void onResponse(String response) {
                SLog.d(response);
            }
        };
    }

    public void request() {
        if (requestQueue == null) {
            requestQueue = App.getApp().getManager(VolleyRequestManager.class).getRequestQueue();
        }
        StringRequest stringRequest = new StringRequest(url, listener, null) {

            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                return header;
            }
        };

        requestQueue.add(stringRequest);

    }
}
